﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Applee.FractCommon;
using System.Drawing;

namespace Applee.SierpinskiFract
{
    class EqualTriangle : BaseShape
    {
        public EqualTriangle()
        {
            points = new PointF[4] 
                { 
                    new PointF(), 
                    new PointF(), 
                    new PointF(),
                    new PointF(), 
                };
        }
        //#region IDrawable 成员

        //public void OnPaint(System.Windows.Forms.PaintEventArgs pe)
        //{
        //    Brush brush = new SolidBrush(mColor);
        //    pe.Graphics.FillPolygon(brush, points);
        //}

        //#endregion

        //#region IShape 成员


        //private PointF[] points = new PointF[4] 
        //{ 
        //    new PointF(), 
        //    new PointF(), 
        //    new PointF(),
        //    new PointF(), 
        //};

        //public PointF[] Points
        //{
        //    get { return points; }
        //    set { points = value; }
        //}

        //private Color mColor = new Color();
        //public Color Color
        //{
        //    get { return mColor; }
        //    set { mColor = value; }
        //}

        //public void MakeShape(System.Drawing.PointF point, float fl)
        //{
        //    float fLength = -fl;
        //    float fH = fLength * 0.25F * (float)Math.Tan(Math.PI / 6.0F);

        //    //(0, L/(2cos30))
        //    points[0] = new PointF(point.X, point.Y + fLength / (float)Math.Cos(Math.PI / 6.0F) * 0.5F - fH);

        //    //(L/2, -L/2 x tan30)
        //    points[1] = new PointF(point.X + fLength * 0.5F, point.Y - fLength * 0.5F * (float)Math.Tan(Math.PI / 6.0F) - fH);

        //    //(-L/2, -L/2 x tan30)
        //    points[2] = new PointF(point.X - fLength * 0.5F, point.Y - fLength * 0.5F * (float)Math.Tan(Math.PI / 6.0F) - fH);

        //    points[3] = points[0];

        //}

        //#endregion
        public override void DoMakeShape(PointF point, float fl)
        {
            float fLength = -fl;
            float fH = fLength * 0.25F * (float)Math.Tan(Math.PI / 6.0F);

            //(0, L/(2cos30))
            points[0] = new PointF(point.X, point.Y + fLength / (float)Math.Cos(Math.PI / 6.0F) * 0.5F - fH);

            //(L/2, -L/2 x tan30)
            points[1] = new PointF(point.X + fLength * 0.5F, point.Y - fLength * 0.5F * (float)Math.Tan(Math.PI / 6.0F) - fH);

            //(-L/2, -L/2 x tan30)
            points[2] = new PointF(point.X - fLength * 0.5F, point.Y - fLength * 0.5F * (float)Math.Tan(Math.PI / 6.0F) - fH);

            points[3] = points[0];
        }
    }
}
